/*
 * Created on Jan 1, 2008
 * 
 * By Erick Audet for OTN
 *
 * Copyright (c) 2008 Oracle Corporation. All Rights Reserved.
 *
 *
 */

package com.sample.services;

import com.sample.accessors.DefaultAccessor;
import com.sample.utils.MyDbEnv;
import com.sleepycat.je.DatabaseException;
import com.sleepycat.je.Transaction;

public class BaseService {


	protected DefaultAccessor defaultAccessor;

	protected Transaction txn;

	
	protected void open(boolean pReadOnly, DefaultAccessor pDefaultAccessor) throws DatabaseException {

		pDefaultAccessor.setEntityStore( MyDbEnv.getInstance().getEntityStore() );
		pDefaultAccessor.init();

	}

	protected void startTransaction() {
			txn = MyDbEnv.getInstance().beginTransaction();
	}

	protected void commit() {
			try {
				txn.commit();
			} catch (DatabaseException e) {
				e.printStackTrace();
			}
	}

}
